package com.scwatch.core.repository;

import com.scwatch.common.orm.Limitable;
import com.scwatch.core.domain.CodeDev;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;

import java.util.Collection;
import java.util.List;

public interface CodeDevDao extends Repository<CodeDev, Integer> {
    Page<CodeDev> findAll(Specification<CodeDev> spec,
                          Pageable pageable);

    List<CodeDev> findAll(Specification<CodeDev> spec,
                          Limitable limitable);

    CodeDev save(CodeDev bean);

    CodeDev findOne(Integer id);

    void delete(CodeDev bean);

    @Modifying
    @Query("delete from CodeDev bean where bean.codeId.id in (?1)")
    int deleteByCodeDevId(Collection<Integer> codeIds);
}
